<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .countDate {
            list-style: none;
        }
        .countDate li {
            float: left;
            display: block;
            width: 25px;
            height: 25px;
            font-size: 20px;
            color: black;
            text-align: center;
            line-height: 25px;
        }
        .countDate .data {
            background-color: black;
            color: white;
        }
    </style>
</head>
<body>
        <ul class="countDate">
            <li>距</li>
            <li>离</li>
            <li>新</li>
            <li>年</li>
            <li>:</li>
            <li class="data"></li>
            <li>天</li>
            <li class="data"></li>
            <li>时</li>
            <li class="data"></li>
            <li>分</li>
            <li class="data"></li>
            <li>秒</li>
        </ul>
    <script>
        let lis= document.querySelector('.countDate').querySelectorAll('li');
        countDown();
        let time2 = setInterval(countDown,1000);
        function countDown() {
            var nowTime = +new Date();
            var inputTIme = +new Date('2021-2-12 0:00:00');
            var times = (inputTIme - nowTime) / 1000; //返回的是当前的秒数
            var second = parseInt(times%60);//当前的秒数
            if (second < 10) second = '0' + second;
            var minute = parseInt(times/60%60);//得到当前分钟数
            if (minute < 10) minute = '0' + minute;
            var hour = parseInt(times/60/60%24);//得到当前的小时
            if (hour < 10) hour = '0' + hour;
            var day = parseInt(times/60/60/24);//得到天
            if (day < 10) day = '0' + day;
            lis[5].innerHTML = day;
            lis[7].innerHTML = hour;
            lis[9].innerHTML = minute;
            lis[11].innerHTML = second;
        }
    </script>
</body>
</html>